package megrez.job.custom.tasks;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;
import megrez.job.common.ShellHelper;

/**
 * Shell任务
 * 
 * @author Lucky Yang
 * @since 2.6.9
 */
@Slf4j
@Component
public class ShellTask {
    public void execute() throws IOException, InterruptedException {
        ShellHelper.execute(List.of("java,-version"), builder -> {
            // 自定义ProcessBuilder， 如设置环境变量
            Map<String, String> environment = builder.environment();
            environment.put("who", "megrez");
        }, log::info);
    }
}
